//
//  LGPopView.m
//  微博
//
//  Created by MS on 15-12-4.
//  Copyright (c) 2015年 MS. All rights reserved.
//

#import "LGPopView.h"

@implementation LGPopView

+(instancetype) showInRect:(CGRect)rect
{
    LGPopView * popView = [[LGPopView alloc] initWithFrame:rect];
    
    popView.userInteractionEnabled = YES;
    
    popView.image = [UIImage imageResizingWithName:@"popover_background"];
    
    [LGKeyWindow addSubview:popView];
    
    return popView;
    
}

+(void) hiddenView
{
    for (UIView * popView in LGKeyWindow.subviews) {
        if ([popView isKindOfClass:self]) {
            
            [popView removeFromSuperview];
        }
    }

}

-(void) setContenView:(UIView *)contenView
{
    [_contenView removeFromSuperview];
    
    _contenView = contenView;
    
    contenView.backgroundColor = [UIColor clearColor];
    
    [self addSubview:contenView];
    
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat margin = 5;
    CGFloat x=margin;
    CGFloat y=9;
    CGFloat w=self.width - 2*margin;
    CGFloat h=self.height - y - margin;
    _contenView.frame = CGRectMake(x, y, w, h);
    
}

@end
